package com.bosssoft.cloud.wechat.core.controller;

import com.bosssoft.cloud.wechat.core.api.MenuService;
import com.bosssoft.cloud.wechat.core.bean.menu.WxMenuParam;
import com.bosssoft.cloud.wechat.infrastructure.bean.response.R;
import com.bosssoft.cloud.wechat.infrastructure.enums.ResultEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 菜单
 *
 * @author wcy create on 2021/7/7 10:51 上午
 */
@Slf4j
@RestController
@RequestMapping("menu")
public class MenuController {
    @Autowired
    private MenuService menuService;

    @PostMapping("create")
    public R<?> create(@RequestBody WxMenuParam param) {
        menuService.create(param);
        return new R<>(ResultEnum.SUCCESS);
    }

    @PostMapping("create_default")
    public R<?> createDefault(
            @RequestParam(name = "url", required = false) String url
    ) {
        menuService.create(url);
        return new R<>(ResultEnum.SUCCESS);
    }
}
